package com.example.chatzsyproject.adapter;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.chatzsyproject.R;
import com.example.chatzsyproject.app.MyApplication;
import com.example.chatzsyproject.model.FriendModel;
import com.example.chatzsyproject.view.AZListView.azlist.AZBaseAdapter;
import com.example.chatzsyproject.view.AZListView.azlist.AZItemEntity;

import java.util.List;

/**
 *
 */
public class ChooseFriendAdapter extends AZBaseAdapter<FriendModel, ChooseFriendAdapter.ItemHolder> {

    public ChooseFriendAdapter(List<AZItemEntity<FriendModel>> dataList) {
        super(dataList);
    }


    @NonNull
    @Override
    public ChooseFriendAdapter.ItemHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ChooseFriendAdapter.ItemHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_choosefriend, parent, false));
    }

    @Override
    public void onBindViewHolder(ChooseFriendAdapter.ItemHolder holder, final int position) {
        Glide.with(MyApplication.getInstance()).load(mDataList.get(position).getValue().getHead_image()).into(holder.im_head);
        holder.mTextName.setText(mDataList.get(position).getValue().getUser_name());
    }

    static class ItemHolder extends RecyclerView.ViewHolder {

        TextView mTextName;
        ImageView im_head;

        ItemHolder(View itemView) {
            super(itemView);
            mTextName = itemView.findViewById(R.id.text_item_name);
            im_head = itemView.findViewById(R.id.im_head);
        }
    }
}
